package com.clw.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.clw.bean.Hangyefenlei;

import db_Util.ConnectHelper;
import net.sf.json.JSONObject;

public class HangyefenleiDao {
	public ArrayList<JSONObject>  query() {
		ArrayList<JSONObject> hangyefenleiArr = new ArrayList<>();
//		JSONObject jsonObject = new JSONObject();
		ConnectHelper ch = new ConnectHelper();
		Connection conn = ch.openConnection();
		try {
			PreparedStatement ps = conn.prepareStatement("select * from t_hangyefenlei");
			ResultSet rs = ps.executeQuery();
			
			while (rs.next()) {
//				Hangyefenlei hangyefenlei = new Hangyefenlei();
				JSONObject jsonObject = new JSONObject();
				jsonObject.put("name",rs.getString("name"));
				jsonObject.put("value",rs.getInt("number"));
				hangyefenleiArr.add(jsonObject);
			}
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		} 
//		map.put("name", hangyefenleiArr1);
//		map.put("number", hangyefenleiArr2);
		return hangyefenleiArr;
	}

}
